package com.itheima;

import java.util.Arrays;

public class KuaiPai {
    public static void main(String[] args) {
        int[] arr = {6, 2, 3, 5, 9, 1, 0, 8, 2, 4, 7};
        System.out.println(Arrays.toString(arr));
        method(arr, 0, arr.length - 1);
        System.out.println(Arrays.toString(arr));
    }

    public static void method(int[] arr, int left, int right) {
        int left0 = left;
        int right0 = right;
        int baseNum = arr[left];
        while (left != right) {
            while (arr[right] >= baseNum && right > left) {
                right--;
            }
            while ((arr[left] <= baseNum && right > left)) {
                left++;
            }
            int temp = arr[left];
            arr[left] = arr[right];
            arr[right] = temp;
        }
        int temp = arr[left];
        arr[left] = arr[left0];
        arr[left0] = temp;
    }
}
